var a = getApp();

Page({
    data: {
        levelId: null,
        levelList: [ {
            name: "直推",
            level: 1
        }, {
            name: "间推",
            level: 2
        } ],
        levelStatus: 1,
        clientData: [],
        clientType: "grade",
        firstLevelCount: 0,
        otherLevelCount: 0,
        page: 1,
        totalPage: 0,
        isLoadMore: !0
    },
    onLoad: function(a) {
        var t;
        "" !== (null !== (t = a.diviLevel) && void 0 !== t ? t : "") && this.setData({
            levelId: Number(a.diviLevel)
        }), this.clientData();
    },
    onReachBottom: function() {
        this.data.isLoadMore ? this.getMoreData() : console.log("没有更多了");
    },
    onPullDownRefresh: function() {
        wx.showNavigationBarLoading(), wx.showLoading({
            title: "刷新中..."
        }), this.setData({
            page: 1
        }), this.clientData();
    },
    onGradeChange: function(a) {
        console.log(a), this.setData({
            levelStatus: a.detail.name,
            page: 1
        }), this.clientData();
    },
    clientData: function() {
        var t = this, e = a.getNetAddresss("plugin.team-analysis.frontend.list.diviList"), i = {
            page: this.data.page,
            divi_level: this.data.levelId,
            level: this.data.levelStatus
        };
        a._getNetWork({
            url: e,
            data: i,
            success: function(a) {
                var e = a.data, i = e.data.data;
                wx.hideLoading(), wx.hideNavigationBarLoading(), wx.stopPullDownRefresh(), 1 == e.result ? (t.data.isLoadMore = !0, 
                t.data.totalPage = e.data.last_page, t.data.totalPage || (t.data.totalPage = 0), 
                t.setData({
                    clientData: i,
                    firstLevelCount: e.data.first_level_count,
                    otherLevelCount: e.data.other_level_count
                })) : (t.data.page = t.data.page - 1, t.isLoadMore = !1, wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                }));
            },
            fail: function(a) {
                console.log(a);
            }
        });
    },
    getMoreData: function() {
        var t = this;
        if (this.data.isLoadMore = !1, !(this.data.page >= this.data.totalPage)) {
            this.data.page = this.data.page + 1;
            var e = a.getNetAddresss("plugin.team-analysis.frontend.list.diviList"), i = {
                page: this.data.page,
                divi_level: this.data.levelId,
                level: this.data.levelStatus
            };
            a._getNetWork({
                url: e,
                data: i,
                success: function(a) {
                    var e = a.data, i = e.data.data;
                    console.log(e), 1 == e.result ? (t.data.isLoadMore = !0, t.setData({
                        clientData: t.data.clientData.concat(i)
                    })) : (t.data.page = t.data.page - 1, wx.showToast({
                        icon: "none",
                        title: e.msg,
                        duration: 1500
                    }));
                },
                fail: function(a) {
                    console.log(a);
                }
            });
        }
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onShareAppMessage: function() {}
});